/*
 * LabelBoard.java
 *
 * Board to display Label Information: its name...
 *
 */

package net.kernub.client;

import com.google.gwt.core.client.GWT;

import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.DeferredCommand;

import com.google.gwt.user.client.ui.SimplePanel;
import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.HorizontalPanel;

import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.Hyperlink;
import com.google.gwt.user.client.ui.Hidden;
import com.google.gwt.user.client.ui.DialogBox;

import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.dom.client.KeyPressEvent;
import com.google.gwt.event.dom.client.KeyPressHandler;
import com.google.gwt.event.dom.client.KeyCodes;

import java.lang.Integer;
import java.util.ArrayList;

import net.kernub.client.core.RPC;
import net.kernub.client.core.RPCCallback;
import net.kernub.client.core.datatype.CInteger;
import net.kernub.client.core.datatype.CBoolean;

import net.kernub.client.wwwConstants;
import net.kernub.client.PageTitled;
import net.kernub.client.LabelData;

import net.kernub.client.datatype.LinkDesc;
import net.kernub.client.datatype.LabelDesc;
import net.kernub.client.datatype.LabelDescArray;


public class LabelBoard extends SimplePanel
{
	public static final String PANEL_WIDTH = "150px";
	private final String STYLE_SELECTED = "LabelBoard_selected";
	private final String STYLE_UNSELECTED = "LabelBoard_unselected";
	private final String STYLE_NAME_SELECTED = "LabelBoard_name_selected";
	private final String STYLE_NAME_UNSELECTED = "LabelBoard_name_unselected";

	private int id = -1;
	private String name = "";
	private String currentStyle = STYLE_UNSELECTED;
	private String currentNameStyle = STYLE_NAME_UNSELECTED;

	final Label nameLabel = new Label();

	public LabelBoard( int id, String name )
	{
		this.id = id;
		this.name = name;

		nameLabel.setText( name );
		nameLabel.addStyleName( "PageText" );
		nameLabel.addStyleName( "LinkCursor" );
		nameLabel.addStyleName( "LabelBoard_name" );
		nameLabel.addStyleName( currentNameStyle );

		setWidth( PANEL_WIDTH );
		setHeight( "auto" );
		addStyleName( "LabelBoard" );
		addStyleName( currentStyle );

		add( nameLabel );
	}

	public void addClickHandler( ClickHandler handler )
	{
		nameLabel.addClickHandler( handler );
	}

	public void selected( final boolean selected )
	{
		String torm = currentStyle;
		String tormname = currentNameStyle;

		if( selected )
		{
			currentStyle = STYLE_SELECTED;
			currentNameStyle = STYLE_NAME_SELECTED;
		}
		else
		{
			currentStyle = STYLE_UNSELECTED;
			currentNameStyle = STYLE_NAME_UNSELECTED;
		}

		nameLabel.removeStyleName( tormname );
		nameLabel.addStyleName( currentNameStyle );
		removeStyleName( torm );
		addStyleName( currentStyle );
	}


};



